$(function(){
    //菜单点击
    $(".J_menuItem").on('click',function(){
        var url = $(this).attr('href');
        var name = $(this).text();
        setCookie("Jname",name);
        $("#J_iframe").attr('src',url);
        return false;
    });
    getOneAdmin1();
});
		
/**
 * 退出登录
 */
function loginout() {
	$.ajax({
		url: urlcore + "/api/admin/logout",
		type: "GET",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
			window.location.href="login.html";
		} else {
			alert(data.msg);
		}
  
		},
		error:function() {
			alert("error");
		}
	});
	
}



function getOneAdmin1() {
    //获取个人信息
	$.ajax({
		url: urlcore + "/api/admin/getThisLogin",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var userName = data.data.userName;
				$('#nick_').text(userName);
				$('#adminId').val(data.data.id);
				myJurisdiction();
			} else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}

			} else if(data.code == 'PARAMETER_INVALID') {
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}
			}
			else {
				alert(data.msg);
			}

		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
}


function myJurisdiction (){
	
	$.ajax({
		url: urlcore + "/api/roleThirdCatalogue/findAllByUser",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				$.each(data.data, function(i,n) {
					$('li[name="'+n.thirdCatalogue.second.first.title+'"]').css("display","block");
					$('li[name="'+n.thirdCatalogue.second.title+'"]').css("display","block");
				});
//				$('li').css("display","block");
			} else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}

			} else if(data.code == 'PARAMETER_INVALID') {
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}
			}
			else {
				alert(data.msg);
			}

		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
	
}





function secondLevel(obj){
//	var name = $(obj).attr('name');
//	$.ajax({
//		url: urlcore + "/api/roleThirdCatalogue/findAllByUser?firstTitle="+name,
//		type: "GET",
//		dataType: 'json',
//		contentType: "application/json;charset=utf-8",
//		success:function(data){
//			if (data.success == true) {
//				var list= $(obj).children("ul").children('li');
//				$.each(data.data, function(m,l) {
//					$.each(list, function(i,n) {
//						if ($(n).attr("name") == l.second.title) {
//							$(n).css('display','block');
//							return;
//						}
//					});
//				});
//		} else {
//			alert(data.msg);
//		}
//
//		},
//		error:function() {
//			alert("error");
//		}
//	});
}


//

